
import { 
  HTTP 
} from "../utils/http.js"

class bookModel extends HTTP {
  getHotList(resolve){
    this.request({
      url:'book/hot_list',
      success: (res)=>{
        resolve(res)
      }
    })
  }
  getDetail(bid,resolve){
    this.request({
      url:'book/'+bid+'/detail',
      success: (res)=>{
        resolve(res)
      }
    })
  }
  getLikeStatus(bid,resolve){
    this.request({
      url:'book/'+bid+'/favor',
      success: (res)=>{
        resolve(res)
      }
    })
  }
  getBookComments(bid,resolve){
    this.request({
      url:'book/'+bid+'/short_comment',
      success: (res)=>{
        resolve(res)
      }
    })
  }
  putBookComments(bid,comment,resolve){
    this.request({
      url:'book/add/short_comment',
      method: 'POST',
      data:{
        book_id: bid,
        content: comment
      },
      success: (res)=>{
        resolve(res)
      }
    })
  }
  bookSearch(start,q,resolve){
    this.request({
      url:'book/search?summary=1',
      data:{
        q: q,
        start: start
      },
      success: (res)=>{
        resolve(res)
      }
    })
  }
}

export {bookModel}
